package listener;

import android.content.Context;
import android.content.Intent;
import android.view.View;

/**
 * Created by YunQisong on 2017/9/2.
 */

public class ToActivityListener implements View.OnClickListener {

    private Context packageContext;

    private Intent intent = new Intent();

    private ToActivityListener() {
    }

    public static ToActivityListener to(Context packageContext, Class<?> cls) {
        ToActivityListener activityListener = new ToActivityListener();
        activityListener.packageContext = packageContext;
        activityListener.intent.setClassName(packageContext, cls.getName());
        return activityListener;
    }

    @Override
    public void onClick(View view) {
        packageContext.startActivity(intent);
    }
}
